package com.liuweiheng.cloud.controller;

import com.liuweiheng.base.entity.R;
import com.liuweiheng.cloud.entity.User;
import com.liuweiheng.cloud.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author lwh
 * @since 2021/5/28
 */
@Api("用户控制器")
@RestController
@RequestMapping("/nacos/user")
@Validated
public class UserController {
    @Autowired
    private UserService userServiceImpl;

    @ApiOperation("创建用户")
    @PostMapping("/create")
    public R create(@RequestBody @Valid User user) {
        userServiceImpl.create(user);
        return R.ok().putData(user.getId());
    }

    @ApiOperation("检查参数")
    @PostMapping("/check")
    public R check(@RequestBody @Valid User user) {
        return R.ok();
    }

}
